package com.szqhyxj.youxiangju.biz.partnerHome.home.merchantdetails;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.szqhyxj.youxiangju.BaseActivity;
import com.szqhyxj.youxiangju.R;
import com.szqhyxj.youxiangju.biz.partnerHome.home.partnerdetails.PartnerDetailsActivity;
import com.szqhyxj.youxiangju.sys.components.HeadportraitView;
import com.szqhyxj.youxiangju.sys.components.NavigationBar;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by leung on 2018/11/21.
 */

public class MerchantDetailsActivity extends BaseActivity implements NavigationBar.NavigationBarListener, MerchantDetailsContract.View {


    MerchantDetailsPresenter presenter;
    @BindView(R.id.navigationBar)
    NavigationBar navigationBar;
    @BindView(R.id.avatar)
    HeadportraitView avatar;
    @BindView(R.id.username)
    TextView username;
    @BindView(R.id.detAddress)
    TextView detAddress;
    @BindView(R.id.idCard)
    TextView idCard;
    @BindView(R.id.repaymentAmtMonth)
    TextView repaymentAmtMonth;
    @BindView(R.id.allRepaymentAmt)
    TextView allRepaymentAmt;
    @BindView(R.id.receivablesAmtMonth)
    TextView receivablesAmtMonth;
    @BindView(R.id.allReceivablesAmt)
    TextView allReceivablesAmt;

    public static void start(Activity activity, String organId, int organType, int statisticsType) {
        Intent intent = new Intent();
        intent.setClass(activity, MerchantDetailsActivity.class);
        intent.putExtra("organId", organId);
        intent.putExtra("organType", organType);
        intent.putExtra("statisticsType", statisticsType);
        activity.startActivity(intent);


    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_merchant_details);
        ButterKnife.bind(this);
        Intent intent = getIntent();
        String organId = intent.getStringExtra("organId");
        int organType = intent.getIntExtra("organType", 0);
        int statisticsType = intent.getIntExtra("statisticsType", 0);
        presenter = new MerchantDetailsPresenter(this);
        presenter.init(organId, organType, statisticsType);
        navigationBar.setNavigationBarListener(this);
    }

    @Override
    public void navigationLeft() {
        finish();
    }

    @Override
    public void navigationRight() {

    }

    @Override
    public void showInfo(MerchantDetailsModel.MerchantDetailsEntity merchantDetailsEntity) {
        username.setText(merchantDetailsEntity.getUsername() + "");
        detAddress.setText(merchantDetailsEntity.getDetAddress() + "");
        idCard.setText(merchantDetailsEntity.getIdCard() + "");
        repaymentAmtMonth.setText(merchantDetailsEntity.getRepaymentAmtMonth() + "");
        allRepaymentAmt.setText(merchantDetailsEntity.getAllRepaymentAmt() + "");
        receivablesAmtMonth.setText(merchantDetailsEntity.getReceivablesAmtMonth() + "");
        allReceivablesAmt.setText(merchantDetailsEntity.getReceivablesAmtMonth() + "");
    }
}
